package com.swf.common.fmt;

import java.io.*;
import java.util.*;

import org.dom4j.*;

import com.swf.common.xml.*;

public class XmlWrap {
	private String tagName;
	private List<XmlFullTag> xmlFullTagList = new ArrayList<XmlFullTag>();
	private List<XmlIColl> xmlICollList = new ArrayList<XmlIColl>();

	public String getTagName() {
		return tagName;
	}

	public void setTagName(String tagName) {
		this.tagName = tagName;
	}

	public List<XmlFullTag> getXmlFullTagList() {
		return xmlFullTagList;
	}

	public void setXmlFullTagList(List<XmlFullTag> xmlFullTagList) {
		this.xmlFullTagList = xmlFullTagList;
	}

	public void addXmlFullTag(XmlFullTag xmlFullTag) {
		this.xmlFullTagList.add(xmlFullTag);
	}

	public void removeXmlFullTag(XmlFullTag xmlFullTag) {
		this.xmlFullTagList.remove(xmlFullTag);
	}

	public List<XmlIColl> getXmlICollList() {
		return xmlICollList;
	}

	public void setXmlICollList(List<XmlIColl> xmlICollList) {
		this.xmlICollList = xmlICollList;
	}

	public void addXmlIColl(XmlIColl xmlIColl) {
		this.xmlICollList.add(xmlIColl);
	}

	public void removeXmlIColl(XmlIColl xmlIColl) {
		this.xmlICollList.remove(xmlIColl);
	}

	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("<xmlWrap tagName=\"" + this.tagName + "\">");
		for (XmlFullTag xmlFullTag : xmlFullTagList) {
			sb.append(xmlFullTag.toString());
		}
		for (XmlIColl xmlIColl : xmlICollList) {
			sb.append(xmlIColl.toString());
		}
		sb.append("</xmlWrap>");
		return sb.toString();
	}
	
	public String toFormatString() {
		try {
			return FwsXmlUtils.formatPrettyXmlWithOutEncoding(toString());
		} catch (DocumentException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}